The present invention relates to an image processing method and apparatus for drawing a bitmap image obtained by rotating an image in an arbitrary area of input bitmap data.
A bitmap rotation method for drawing bit map images obtained by rotating an image in an arbitrary area of input bitmap data through 90.degree..times. n (n=1, 2, 3) includes the following methods. In the following description, the rotation angle represents that in the counterclockwise direction, and the leftmost pixel corresponds to bit 7 unless otherwise specified.
FIG. 5 summarizes a principal part of conventional 90.degree. rotation processing of an image.
The rotation processing is performed in units of 8-byte blocks each consisting of 1 byte.times.8 lines (8.times.8 pixels). Referring to FIG. 5, p.sub.-- from and p.sub.-- to are respectively the output and input pointers of a block to be processed, and a suffix [n] indicates an address advanced by n bytes. For example, p.sub.13 from[2] indicates an address advanced by 2 bytes from p.sub.-- from[0]. row.sub.-- from and row.sub.-- to are the numbers of bytes per line of images before and after rotation, and work is a work variable for the rotation processing.
A symbol "=" represents substitution from the right-hand side to the left-hand side, and a symbol ":=" represents substitution of the OR of the right- and left-hand sides into the left-hand side. On the other hand, a symbol "+=" represents addition of the right-hand side to the left-hand side.
In step S51, initialization is performed, i.e., variables such as a pointer p.sub.-- from indicating a block to be rotated, a pointer p.sub.-- to indicating a rotated block, and the like are initialized.
Steps S52-1 to S52-8 correspond to the main rotation processing. In order to generate data of one rotated block (8 bytes), 8-byte data of an original block is transferred to a variable work in units of pixels per operation to generate rotated data in the variable work, and the rotated data is written in a buffer indicated by the pointer p.sub.-- to.
In steps S52-1 to S52-8, the respective columns of a non-processed block (8 rows.times.8 columns) are moved to the respective rows of a processed block. In step S52-1, pixels in the rightmost column of the non-processed block are moved to the uppermost row of the processed block. Note that words "right, left, up, and down" indicate the corresponding positions when an 8 (pixels) .times.8 (pixels) block is visually considered. In this case, the pixels are moved as follows. That is, a pixel in the leftmost column of an i-th row of a non-processed block is moved to an i-th column of the uppermost row of a processed block. This movement is repeated in turn for i=1 to 8. Similarly, in step S52-2, the second column from the right side of the non-processed block is moved to the second row of the processed block. In this manner, the pixels are sequentially moved up to the eighth column to rotate one block through 90.degree..
Upon completion of step S52, the flow returns to step S51 to process the next block.
FIGS. 6A and 6B show conventional 180.degree. rotation processing. FIG. 6A shows a case wherein a 256-byte look-up table (LUT) is used, and FIG. 6B shows a case wherein movement in units of pixels is repeated as in the conventional 90.degree. rotation processing. In the example using the LUT, a non-processed block is converted using an LUT "table" in units of rows, i.e., bytes to obtain a converted block. The LUT "table" has a value obtained by reversing the order of a binary value i as the contents of an i-th byte from the beginning. For example, the (0.times.05)-th byte of the LUT "table" has a value 0.times.A0 obtained by reversing its order as a binary value. For this reason, in step S602, a value obtained by rotating a byte indicated by a pointer p.sub.-- from through 180.degree. is assigned to a processed block indicated by a pointer p.sub.-- to. Every time one row is processed, the pointer p.sub.-- from is advanced by one row and the pointer p.sub.-- to is returned by one row. When this processing is performed for eight rows, rotation of one block is completed.
In FIG. 6B, in step S612, one row (one byte) of a non-processed block is reversed, i.e., rotated through 180.degree.. This processing is performed in turn from upper rows of the non-rotated block, and the rotated rows are assigned in turn from the lower rows of a rotated block, thereby obtaining a block rotated through 180.degree..
In this connection, the 90.degree. rotation processing may use an LUT.
However, in the conventional method, since processing is performed in units of bits, the processing speed is low. In addition, in order to perform processing in units of bits, data must be accessed for each processing unit including a target bit, e.g., in units of bytes. For this reason, the processing time is further prolonged since 8-byte data must be accessed each time rotated one-byte data is generated. Such long processing time becomes conspicuous in a system having no data cache. Although a 16-bit processor can perform a 16-bit arithmetic operation and a 32-bit processor can perform a 32-bit arithmetic operation, a portion actually used in the arithmetic operation is only an 8-bit (1-byte) portion, resulting in wasteful processing.
When the LUT is used, since the number of data accesses increases, a data cache is preferably arranged to attain high-speed processing. In order to attain higher-speed processing using the LUT, assume that the table size is increased, e.g., is changed to convert a block in units of 2 bytes so as to decrease the number of accesses. In this case, the table size in units of bytes is 1.times.2.sup.8 bytes, while the table size in units of 2 bytes is 2.times.2.sup.16 bytes, i.e., becomes 512 times that in units of bytes. However, as compared to this increase in table size, the number of accesses to the LUT can only be halved, resulting in very poor efficiency. On the contrary, in a system having a data cache, the cache hit rate may lower, and the system speed may decrease.
As an equipment to which image rotation is applied, a digital copying machine is known.
In a digital copying machine, an original image or the like is optically read, and an image is formed on a recording sheet after digital processing. In such an apparatus, document sheets including a plurality of pages are read in turn, and images can be formed on recording sheets. The direction of a copied document image has a one-to-one correspondence with that of an original document image provided to the apparatus. In an electronic filing apparatus as well, a read image is displayed on a display in correspondence with the read direction.
Therefore, when a document image is input, a copied document image cannot have a normal direction unless a document image is input in a normal direction. For example, when one of a plurality of document pages is set upside down, only a document image corresponding to the page is copied upside down. When a copying operation is executed in this state, the user must confirm the page after he or she inputs documents, and must adjust the document directions by picking up the page set in the wrong direction. In the electronic filing apparatus, a document page read in a wrong direction must be set again on a reader in a normal direction and subjected to read processing again, or an input document image must be rotated by user's designation.
As described above, in the conventional digital copying machine or electronic filing apparatus, when an original image is input in a wrong direction, the user is required to perform some correction operations, resulting in a heavy load on the user.